import { ContarctData } from "@/services/api/finance";
import { createSlice, PayloadAction } from "@reduxjs/toolkit";

const initPage = { pageNo: 1, pageSize: 10 };

const initSearch = {
  contractNo: "",
  contact: "",
  tel: "",
};

export interface ContractStateType {
    page: {pageNo: number, pageSize: number},
    search: {contractNo: string, contact: string, tel: string},
    total: number,
    list: ContarctData[],
}

const INITSTATE: ContractStateType = {
    page: initPage,
    search: initSearch,
    total: 0,
    list: [],
}

export const contractSlice = createSlice({
    name: 'contract',
    initialState: INITSTATE,
    reducers: {
        reset: (state, action: PayloadAction<ContractStateType>) => {
            return action.payload;
        }
    }
})

export const {reset} = contractSlice.actions;
export default contractSlice.reducer;